import tkinter as tk
from tkinter import messagebox
import requests

# 获取舔狗日记内容
def fetch_tiangou():
    try:
        response = requests.get("https://api.52vmy.cn/api/wl/yan/tiangou")
        response.raise_for_status()  # 检查请求是否成功
        data = response.json()
        content = data.get("content", "内容获取失败")
        text_box.delete(1.0, tk.END)  # 清空文本框
        text_box.insert(tk.END, content)  # 显示内容
    except requests.RequestException as e:
        messagebox.showerror("错误", f"网络请求失败: {e}")
    except ValueError as e:
        messagebox.showerror("错误", f"解析内容失败: {e}")

# 创建主窗口
root = tk.Tk()
root.title("舔狗日记")
root.geometry("600x400")  # 放大窗口大小

# 设置字体大小
font_size = ("Arial", 14)  # 使用 Arial 字体，大小为 14

# 创建文本框
text_box = tk.Text(root, wrap=tk.WORD, state="normal", height=10, width=40, font=font_size)
text_box.pack(pady=20)  # 增加上下间距

# 创建按钮
fetch_button = tk.Button(root, text="获取新的舔狗日记", command=fetch_tiangou, font=font_size)
fetch_button.pack(pady=10)  # 增加上下间距

# 运行主循环
root.mainloop()